import { request } from "@/utils/http";
import type {
  HospitalShowResponse,
  ProvinceItems,
  ReqGetDepartmentsResponse,
  ReqGetDoctorsParams,
  ReqGetDoctorsResponse,
  ReqGetHospitalListParams,
  ReqGetScheduleRulesParams,
  ReqGetScheduleRulesResponse,
  ReqHospitalListResponse,
} from "./model/hospitalListType";

// export function reqGetHospitalList(hospital: ReqGetHospitalListParams){
//   return request.get<any, ReqHospitalListResponse>(`/admin/hosp/hospital/${hospital.page}/${hospital.limit}`, {
//     //设置 query 参数
//     params: {
//       hoscode: hospital.hoscode,
//       hosname: hospital.hosname,
//       hostype: hospital.hostype,
//       provinceCode: hospital.provinceCode,
//       cityCode: hospital.cityCode,
//       districtCode: hospital.districtCode,
//       status: hospital.status
//     }
//   })
// }

/**
 * 获取医院列表
 * @param param0 医院查询条件的对象
 * @returns  Promise<ReqHospitalListResponse>
 */
export function reqGetHospitalList({
  page,
  limit,
  ...args
}: ReqGetHospitalListParams) {
  return request.get<any, ReqHospitalListResponse>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      //设置 query 参数
      params: args,
    }
  );
}

/**
 * 获取省份信息
 * @returns Promise<ProvinceItems>
 */
export function reqGetProvince() {
  return request.get<any, ProvinceItems>(
    "/admin/cmn/dict/findByDictCode/province"
  );
}

/**
 * 通过 id 获取城市或者区县的信息
 * @param parentId 省份或者城市的 id
 * @returns Promise<ProvinceItems>
 */
export function reqGetCityOrDistrict(parentId: number) {
  return request.get<any, ProvinceItems>(
    `/admin/cmn/dict/findByParentId/${parentId}`
  );
}

/**
 * 通过 id 获取医院的详细内容
 * @param id 医院的 id 编号
 * @returns  Promise<HospitalShowResponse>
 */
export function reqGetHospitalShow(id: string) {
  return request.get<any, HospitalShowResponse>(
    `/admin/hosp/hospital/show/${id}`
  );
}

/**
 * 获取医院的科室
 * @param hoscode 医院的编号
 * @returns Promise<ReqGetDepartmentsResponse>
 */
export function reqGetHospitalDepartment(hoscode: string) {
  return request.get<any, ReqGetDepartmentsResponse>(
    `/admin/hosp/department/${hoscode}`
  );
}

/**
 * 获取某个医院某个科室的排班规则
 * @param param0 排班规则请求的参数
 * @returns Promise<ReqGetScheduleRulesResponse>
 */
export function reqGetHospitalSchedule({
  page,
  limit,
  hoscode,
  depcode,
}: ReqGetScheduleRulesParams) {
  return request.get<any, ReqGetScheduleRulesResponse>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  );
}

/**
 * 获取某个医院某个科室某天出诊医生的列表
 * @param param0 请求参数
 * @returns Promise<ReqGetDoctorsResponse>
 */
export function reqGetDoctors({
  hoscode,
  depcode,
  workDate,
}: ReqGetDoctorsParams) {
  return request.get<any, ReqGetDoctorsResponse>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  );
}

/**
 * 更新某个医院的状态
 * @param id 医院的 id 编号
 * @param status 医院更新成的状态
 * @returns Promise<any>
 */
export function reqUpdateHospitalStatus(id: string, status: number) {
  return request.get<any, any>(`/admin/hosp/hospital/updateStatus/${id}/${status}`);
}
